package com.yuchen.ishop.service.seller;

import com.yuchen.core.MyPager;
import com.yuchen.ishop.entity.Seller;

import com.yuchen.ishop.entity.SellerXiaoer;
import com.yuchen.ishop.entity.Shop;
import com.yuchen.jaxrs.restclient.RestClientUtils;
import com.yuchen.jaxrs.Responses;
import com.yuchen.utils.config.ConfigUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;


import java.util.HashMap;
import java.util.Map;

/**
 *
 */
@Service
public class SellerRestClient {

    private final static Logger LOG = Logger.getLogger(SellerRestClient.class);

    public Seller getById(Long id) {
        String url = ConfigUtils.config.get("seller_getById");
        Map map = new HashMap(1);
        map.put("id", id);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.get(Seller.class, url);
    }

    public Seller insert(Seller seller) {
        String url = ConfigUtils.config.get("seller_insert");
        return RestClientUtils.post(Seller.class, seller, url);
    }



    public Responses existGoods(Long userId, Long goodsId,String role) {
        String url = ConfigUtils.config.get("goods_exist");
        Map map = new HashMap(2);
        map.put("userId", userId); //可能是sellerId,xiaoerId,buyerId
        map.put("id", goodsId);
        map.put("role", role);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.get(Responses.class, url);
    }

    public Responses update(Seller seller) {
        String url = ConfigUtils.config.get("seller_update");
        return RestClientUtils.post(Responses.class, seller, url);
    }

    public Responses updatePwd(Map map) {
        String url = ConfigUtils.config.get("seller_updatePwd");
        return RestClientUtils.post(Responses.class, map, url);
    }
}